package com.wanpinghui.supplier.object;

import android.content.Intent;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.TextView;

import com.wanpinghui.supplier.R;
import com.wanpinghui.supplier.common.BaseActivity;
import com.wanpinghui.supplier.widgets.TitlePanelLayout;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;

/***
 * 功能描述:
 * 作者:qiujialiu
 * 时间:2017/12/2
 ***/
@ContentView(R.layout.layout_activity_feedback)
public class FeedBackActivity extends BaseActivity {
    @ViewInject(R.id.tpl_title)
    private TitlePanelLayout mLayoutTtite;
    @ViewInject(R.id.tv_reason1)
    private TextView textViewReason1;
    @ViewInject(R.id.tv_reason2)
    private TextView textViewReason2;
    @ViewInject(R.id.tv_reason3)
    private TextView textViewReason3;
    @ViewInject(R.id.tv_object_desception)
    private TextView textViewDesception;

    private long demandId;
    private long successAt;
    private String description;
    private boolean isDispatch;//是否派单
    private boolean isCanLock;

    @Override
    public String getName() {
        return null;
    }

    @Override
    public boolean isBar() {
        return false;
    }

    @Override
    public void initViews() {
        if (getIntent() != null) {
            demandId = getIntent().getLongExtra("id", 0);
            successAt = getIntent().getLongExtra("success_at", 0);
            description = getIntent().getStringExtra("desception");
            isDispatch = getIntent().getBooleanExtra("dispatch", false);
            isCanLock = getIntent().getBooleanExtra("lock", true);
        }
        System.out.println("**************************************");
        System.out.println(successAt);
        System.out.println("**************************************");
    }

    @Override
    public void bindEvents() {
        textViewReason1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        mLayoutTtite.setOnClickBacktrack(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        textViewReason2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(FeedBackActivity.this, FeedBackConfirmActivity.class);
                intent.putExtra("id", demandId);
                intent.putExtra("success_at", successAt);
                System.out.println("**************************************");
                System.out.println(successAt);
                System.out.println("**************************************");
                intent.putExtra("type", 1);
                intent.putExtra("dispatch", isDispatch);
                startActivity(intent);
            }
        });

        textViewReason3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(FeedBackActivity.this, FeedBackConfirmActivity.class);
                intent.putExtra("id", demandId);
                intent.putExtra("success_at", successAt);
                intent.putExtra("type", 2);
                intent.putExtra("dispatch", isDispatch);
                startActivity(intent);
            }
        });

        if (isCanLock) {
            textViewReason2.setEnabled(true);
            textViewReason2.setTextColor(ContextCompat.getColor(this, R.color.colorTextPrimaryOne));
        } else {
            textViewReason2.setEnabled(false);
            textViewReason2.setTextColor(ContextCompat.getColor(this, R.color.colorTextPrimaryTwo));

        }
    }

    @Override
    public void initData() {
        textViewDesception.setText(description);
    }
}
